home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / mda_spy.com / MDA_SPY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-01  |  3.8 KB  |  146 lines

  1. #include "windows.h"
  2. #include "mda_spy.h"
  3. #include "time.h"
  4. #include "io.h"
  5. #include "stdio.h"
  6.  
  7. char szAppName[10];
  8. char szMessage[15];
  9. int MessageLength;
  10.  
  11. static HANDLE hInst;
  12. extern void spycls(void);
  13. extern void spystr(char *,char,char);
  14. extern void spytoa(int,char,char);
  15. extern void spyarr(char ,int,char,char);
  16.  
  17. long FAR PASCAL Mda_SpyWndProc(HWND, unsigned, WORD, LONG);
  18.  
  19.  
  20. void Mda_SpyPaint( hDC )
  21. HDC hDC;
  22. {
  23.     TextOut( hDC,
  24.              (short)10,
  25.              (short)10,
  26.              (LPSTR)szMessage,
  27.              (short)MessageLength );
  28. }
  29.  
  30.  
  31. BOOL Mda_SpyInit( hInstance )
  32. HANDLE hInstance;
  33. {
  34.     PWNDCLASS   pMda_SpyClass;
  35.  
  36.     LoadString( hInstance, IDSNAME, (LPSTR)szAppName, 10 );
  37.     MessageLength = LoadString( hInstance, IDSTITLE, (LPSTR)szMessage, 15 );
  38.  
  39.     pMda_SpyClass = (PWNDCLASS)LocalAlloc( LPTR, sizeof(WNDCLASS) );
  40.  
  41.     pMda_SpyClass->hCursor        = LoadCursor( NULL, IDC_ARROW );
  42.     pMda_SpyClass->hIcon          = LoadIcon( hInstance, MAKEINTRESOURCE(SPYICON) );
  43.     pMda_SpyClass->lpszMenuName   = (LPSTR)NULL;
  44.     pMda_SpyClass->lpszClassName  = (LPSTR)szAppName;
  45.     pMda_SpyClass->hbrBackground  = (HBRUSH)GetStockObject( WHITE_BRUSH );
  46.     pMda_SpyClass->hInstance      = hInstance;
  47.     pMda_SpyClass->style          = CS_HREDRAW | CS_VREDRAW;
  48.     pMda_SpyClass->lpfnWndProc    = Mda_SpyWndProc;
  49.  
  50.     if (!RegisterClass( (LPWNDCLASS)pMda_SpyClass ) )
  51.         return FALSE;
  52.  
  53.     LocalFree( (HANDLE)pMda_SpyClass );
  54.     return TRUE;        /* Initialization succeeded */
  55. }
  56.  
  57.  
  58. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  59. HANDLE hInstance, hPrevInstance;
  60. LPSTR lpszCmdLine;
  61. int cmdShow;
  62. {
  63.     MSG   msg;
  64.     HWND  hWnd;
  65.     HMENU hMenu;
  66.  
  67.     if (!hPrevInstance) {
  68.         if (!Mda_SpyInit( hInstance ))
  69.             return FALSE;
  70.         }
  71.     else {
  72. PostQuitMessage(0);        }
  73.  
  74.     hWnd = CreateWindow((LPSTR)szAppName,
  75.                         (LPSTR)szMessage,
  76.                         WS_OVERLAPPEDWINDOW,
  77.                         0,    /*  x - ignored for tiled windows */
  78.                         0,    /*  y - ignored for tiled windows */
  79.                         100,    /* cx - ignored for tiled windows */
  80.                         100,    /* cy - ignored for tiled windows */
  81.                         (HWND)NULL,        /* no parent */
  82.                         (HMENU)NULL,       /* use class menu */
  83.                         (HANDLE)hInstance, /* handle to window instance */
  84.                         (LPSTR)NULL        /* no params to pass on */
  85.                         );
  86.  
  87.     hInst = hInstance;
  88.  
  89.  
  90.     hMenu = GetSystemMenu(hWnd, FALSE);
  91.     ChangeMenu(hMenu, 0, NULL, 999, MF_APPEND | MF_SEPARATOR);
  92.     ChangeMenu(hMenu, 0, (LPSTR)"MDA_SPY", IDSABOUT, MF_APPEND | MF_STRING);
  93.  
  94.     ShowWindow( hWnd, cmdShow );
  95.     UpdateWindow( hWnd );
  96.  
  97.     while (GetMessage((LPMSG)&msg, NULL, 0, 0)) {
  98.         TranslateMessage((LPMSG)&msg);
  99.         DispatchMessage((LPMSG)&msg);
  100.         }
  101.  
  102.     return (int)msg.wParam;
  103. }
  104.  
  105.  
  106. long FAR PASCAL Mda_SpyWndProc( hWnd, message, wParam, lParam )
  107. HWND hWnd;
  108. unsigned message;
  109. WORD wParam;
  110. LONG lParam;
  111. {
  112.     PAINTSTRUCT ps;
  113.     HMENU hMenu;
  114.     switch (message)
  115.     {
  116.     case WM_SYSCOMMAND:
  117.         switch (wParam)
  118.         {
  119.         case IDSABOUT:
  120.         spycls();
  121.         spystr("Hello says the echo",10,2);
  122.         spytoa(20,11,3);
  123.         break;
  124.  
  125.         default:
  126.             return DefWindowProc( hWnd, message, wParam, lParam );
  127.         }
  128.         break;
  129.  
  130.     case WM_DESTROY:
  131.         PostQuitMessage( 0 );
  132.         break;
  133.  
  134.     case WM_PAINT:
  135.         BeginPaint( hWnd, (LPPAINTSTRUCT)&ps );
  136.         Mda_SpyPaint( ps.hdc );
  137.         EndPaint( hWnd, (LPPAINTSTRUCT)&ps );
  138.         break;
  139.  
  140.     default:
  141.         return DefWindowProc( hWnd, message, wParam, lParam );
  142.         break;
  143.     }
  144.     return(0L);
  145. }
  146.